<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>分类管理</title>
    <div th:replace="admin/common::menu"></div>
</head>
<body>
<div id="app">
    <div class="main-wrapper">
        <div class="navbar-bg"></div>
        <!--导航栏-->
        <div th:replace="admin/common::headermenu"></div>
        <!--侧边栏-->
        <div th:replace="admin/common::leftmenu(3)"></div>
    </div>
    <div class="main-content">
        <section class="section">
            <h1 class="section-header">
                <div>分类管理</div>
            </h1>
        </section>
        <div class="ui container">

            <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
                <i class="close icon"></i>
                <div class="header">提示：</div>
                <p th:text="${message}">操作成功！</p>
            </div>

            <div class="ui container">
                <a th:href="@{/admin/toAddclassify}" class="ui mini teal basic button">新增</a>
            </div>
            <table  class="ui compact teal table">
                <thead>
                <tr>
                    <th></th>
                    <th>名称</th>
                    <th>文章数</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="type,iterStat:${types}">
                    <td>[[${iterStat.count}]]</td>
                    <td>[[${type.name}]]</td>
                    <td>[[${type.count}]]</td>
                    <td>
                        <a class="ui mini teal basic button" th:href="@{/admin/editClassify(id=${type.id},name=${type.name})}">编辑</a>
                        <a class="ui mini red basic button delete" th:href="@{/admin/deleteClassify(id=${type.id})}">删除</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<div th:replace="admin/common::srciptmenu"></div>
<script type="text/javascript">
    $(function () {
        $("a.delete").click(function () {
            return confirm("确定要删除【"+$(this).parent().parent().find("td:first+td").text()+"】分类吗？该分类下的所有内容将会被删除");
        })

        //消息提示关闭初始化
        $('.message .close').on('click',function () {
            $(this).closest('.message').transition('fade');
        });
    })
</script>
</body>
</html>